<h1><%= t ".title" %></h1>

<p><%= t ".description" %></p>
<ul>
  <li><%= t ".archives-only" %></li>
  <li><%= t ".non-archives" %></li>
</ul>

<%= form_with model: @model, id: "upload-form", class: "container-md tabular-form" do |form| %>

  <% if SiteSettings.show_libraries %>
    <div>
      <%= form.label :library, Library.model_name.human %>
    </div>
    <div>
      <%= form.select :library,
            policy_scope(Library).all.map { |lib| [library_select_title(lib), lib.to_param] },
            {include_blank: false, selected: Library.default.to_param},
            {class: "form-control form-select"} %>
      <span class="form-text"><%= t ".library.help" %></span>
    </div>
  <% end %>

  <div>
    <%= form.label :files, t(".files.label"), class: "col-sm-2 col-form-label" %>
  </div>
  <div>
    <%= content_tag :div, nil, data: {
          turbo_permanent: true,
          controller: "upload",
          action: "turbo:morph@window->upload#reconnect",
          max_file_size: SiteSettings.max_file_upload_size,
          allowed_file_types: input_accept_string,
          archive_extensions: SupportedMimeTypes.archive_extensions.join(","),
          upload_endpoint: upload_path
        } %>

    <div class="alert alert-info" id="multi-model-message" style="display: none">
      <%= Icon(icon: "boxes", role: "presentation") %>
      <%= t(".multi_model") %>
    </div>

    <div class="alert alert-info" id="single-model-message" style="display: none">
      <%= Icon(icon: "box", role: "presentation") %>
      <%= t(".single_model") %>
    </div>
  </div>

  <%= text_input_row form, :name, label: t(".model_name.label"), help: t(".model_name.help") %>

  <%= render "bulk_fields", form: form %>

  <%= render "tags_edit", form: form, name: "model[tag_list]", selected: SiteSettings.model_tags_auto_tag_new, label: ActsAsTaggableOn::Tag.model_name.human(count: 100), tags: @available_tags || [] %>

  <div>
    <%= form.label translate(".permission_preset"), for: :permission_preset %>
  </div>
  <div>
    <%= form.select :permission_preset, [
          [translate("settings.multiuser.default_viewer_role.options.private"), "private"],
          [translate("settings.multiuser.default_viewer_role.options.member"), "member"],
          [translate("settings.multiuser.default_viewer_role.options.public"), "public"]
        ],
          {selected: SiteSettings.default_viewer_role, include_blank: true},
          {class: "form-control col-auto form-select"} %>
  </div>

  <div class="row mb-3 input-group">
    <div class='offset-sm-2 col-sm-10 ps-0'>
      <%= submit_tag translate(".submit"), class: "btn btn-primary" %>
    </div>
  </div>
<% end %>
